package com.example.ljw.frescowallpaper.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.ljw.frescowallpaper.R;
import com.example.ljw.frescowallpaper.bean.MyFirstBean;
import com.example.ljw.frescowallpaper.bean.MyWallbean;
import com.example.ljw.frescowallpaper.utils.RecyclerViewAdapterHelper;
import com.example.ljw.frescowallpaper.view.Details;
import com.example.ljw.frescowallpaper.view.NavigationActivity;

import java.util.List;

/**
 * Created by LJW on 2016/11/15.
 */

public class MyRecyclerAdapter extends RecyclerViewAdapterHelper<MyFirstBean.ResBean.DataBean> {

    private static final String TAG = "======================";

    public MyRecyclerAdapter(Context context, List<MyFirstBean.ResBean.DataBean> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view=mInflater.inflate(R.layout.item_layout,parent,false);
        return new ViewHolder1(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
     String  imgUrl=mList.get(position).getUrl();
//        Log.e(TAG,position+">>>"+imgUrl);

        ViewHolder1 holder1= (ViewHolder1) holder;
        Glide.with(mContext)
                .load(imgUrl)
                .placeholder(R.mipmap.wallpaper)
                .centerCrop()
                .into(holder1.imageView_item);

    }
    class ViewHolder1 extends RecyclerView.ViewHolder implements View.OnClickListener{
        private ImageView imageView_item;

        public ViewHolder1(View itemView) {
            super(itemView);
            imageView_item= (ImageView) itemView.findViewById(R.id.img_item);
            imageView_item.setOnClickListener(this);
        }

        @Override
        public void onClick(View view) {
            Intent intent =new Intent(mContext,Details.class);
            intent.putExtra("URL",mList.get(getAdapterPosition()).getUrl());
            mContext.startActivity(intent);
        }
    }
}
